package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.MesGetMat;
import com.ruoyi.system.service.IMesGetMatService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 领料出库Controller
 * 
 * @author ruoyi
 * @date 2024-06-01
 */
@RestController
@RequestMapping("/system/mat")
public class MesGetMatController extends BaseController
{
    @Autowired
    private IMesGetMatService mesGetMatService;

    /**
     * 查询领料出库列表
     */
    @PreAuthorize("@ss.hasPermi('system:mat:list')")
    @GetMapping("/list")
    public TableDataInfo list(MesGetMat mesGetMat)
    {
        startPage();
        List<MesGetMat> list = mesGetMatService.selectMesGetMatList(mesGetMat);
        return getDataTable(list);
    }

    /**
     * 导出领料出库列表
     */
    @PreAuthorize("@ss.hasPermi('system:mat:export')")
    @Log(title = "领料出库", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MesGetMat mesGetMat)
    {
        List<MesGetMat> list = mesGetMatService.selectMesGetMatList(mesGetMat);
        ExcelUtil<MesGetMat> util = new ExcelUtil<MesGetMat>(MesGetMat.class);
        util.exportExcel(response, list, "领料出库数据");
    }

    /**
     * 获取领料出库详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:mat:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id)
    {
        return AjaxResult.success(mesGetMatService.selectMesGetMatById(id));
    }

    /**
     * 新增领料出库
     */
    @PreAuthorize("@ss.hasPermi('system:mat:add')")
    @Log(title = "领料出库", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MesGetMat mesGetMat)
    {
        return toAjax(mesGetMatService.insertMesGetMat(mesGetMat));
    }

    /**
     * 修改领料出库
     */
    @PreAuthorize("@ss.hasPermi('system:mat:edit')")
    @Log(title = "领料出库", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MesGetMat mesGetMat)
    {
        return toAjax(mesGetMatService.updateMesGetMat(mesGetMat));
    }

    /**
     * 删除领料出库
     */
    @PreAuthorize("@ss.hasPermi('system:mat:remove')")
    @Log(title = "领料出库", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids)
    {
        return toAjax(mesGetMatService.deleteMesGetMatByIds(ids));
    }



}
